package com.findu.view;

import java.util.ArrayList;
import java.util.List;



import com.example.findu.R;
import com.example.findu.R.drawable;
import com.example.findu.R.id;
import com.example.findu.R.layout;
import com.findu.control.Activity_selectdyNamic_gardenful_MYAdapter;
import com.findu.control.Public_title;
import com.findu.model.App;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ListView;
import android.widget.Toast;

/**
 * 
* @ClassName: Activity_view_selectdynamic_gardenful 
* @Description: TODO(主页第二个页面) 
* @author hgf
* @date 2015-11-4 上午10:59:01 
*
 */
public class Activity_view_selectdynamic_gardenful extends Activity {
	//声明标题
	private Public_title public_title;
	private View public_title_view;

	//存放结果变量
		private App app0,app1,app2,app3;
		private List<App> listData;
		
		//声明listview
		private ListView main_listview;
		//声明适配器
		private Activity_selectdyNamic_gardenful_MYAdapter myAdapter;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_view_selectdynamic_gardenful);
		
		//初始化Title
		init_Title();
		

		//绑定列表内容及适配
		init_list();
		
	}
	
	/**
	 * 初始化listView
	 */
	private void init_list() {
		// TODO Auto-generated method stub
		//初始化listview
				main_listview = (ListView) findViewById(R.id.Activity_view_selectdynamic_gardenful_listview);
				
				app0 = new App();
				app0.setJurisdiction("完全公开");
				app0.setName("公开");
				app0.setYsNo(1);	
				
				app1 = new App();
				app1.setJurisdiction("隐私");
				app1.setName("仅自己可见");
				app1.setYsNo(1);	
				
				app2 = new App();
				app2.setJurisdiction("家族内的用户");
				app2.setName("家族内可见");
				app2.setYsNo(1);	
				
				app3 = new App();
				app3.setJurisdiction("非家族成员");
				app3.setName("仅陌生人可见");
				app3.setYsNo(1);	
				
				listData = new ArrayList<App>();
				listData.add(app0);
				listData.add(app1);
				listData.add(app2);
				listData.add(app3);
				
				//声明Handler修改ui层
				final Handler handler = new Handler(){
					@Override
					public void handleMessage(Message msg) {
						switch (msg.what) {
						case 1:
							myAdapter = new Activity_selectdyNamic_gardenful_MYAdapter(Activity_view_selectdynamic_gardenful.this, listData);
							main_listview.setAdapter(myAdapter);
							break;

						default:
							break;
						}
						super.handleMessage(msg);
					}
				};
				
				handler.sendEmptyMessage(1);
				//Toast.makeText(Activity_view_selectdynamic_gardenful.this, "空", Toast.LENGTH_SHORT).show();
	}

	/**
	 * 初始化标题
	 */
	private void init_Title() {
		// TODO Auto-generated method stub
		//设置标题
				public_title_view = findViewById(R.id.Activity_view_selectdynamic_gardenful_include);
				public_title = new Public_title(public_title_view);
				public_title.setLeftImage(R.drawable.back);
				public_title.setTextView("动态");
				
				public_title_view.findViewById(R.id.public_title_liftImage).setOnClickListener(new OnClickListener() {
					
					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						
						finish();
					}
				});
	}


}
